package com.example.zhang.controller;

import com.example.zhang.dto.*;
import com.example.zhang.service.CabinetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api")
public class CabinetController {
    @Autowired
    private CabinetService cabinetService;

    

    @GetMapping("/cabinet/status")
    public ResponseEntity<CabinetStatusResponse> getCabinetStatus() {
        return ResponseEntity.ok(cabinetService.getCabinetStatus());
    }

    @PostMapping("/cabinet/drawer/switch")
    public ResponseEntity<BaseResponse> switchDrawer(@RequestBody DrawerSwitchRequest request) {
        return ResponseEntity.ok(cabinetService.switchDrawer(request));
    }

    @PostMapping("/cabinet/temp-control")
    public ResponseEntity<BaseResponse> tempControl(@RequestBody TempControlRequest request) {
        return ResponseEntity.ok(cabinetService.tempControl(request));
    }

    @PostMapping("/cabinet/set-temp")
    public ResponseEntity<BaseResponse> setTemp(@RequestBody SetTempRequest request) {
        return ResponseEntity.ok(cabinetService.setTemp(request));
    }

    @PostMapping("/cabinet/params")
    public ResponseEntity<BaseResponse> setParams(@RequestBody SetParamsDTO request) {
        return ResponseEntity.ok(cabinetService.setParams(request));
    }
} 